Current Location: Home> Function Categories> strftime

strftime

Format local time/date according to locale settings
Name:strftime
Category:Date and time
Programming Language:php
One-line Description:Format local time/date according to locale settings.

Definition and usage

strftime() function formats the local date and time according to the locale settings.

Tip: See the gmstrftime() function to format the GMT/UTC time/date according to the locale settings.

Example

Format local date and time according to locale settings:

 <?php
echo ( strftime ( "%B %d %Y, %X %Z" , mktime ( 20 , 0 , 0 , 12 , 31 , 98 ) ) . "<br>" ) ;
setlocale ( LC_ALL , "hu_HU.UTF8" ) ;
echo ( strftime ( "%Y. %B %d. %A. %X %Z" ) ) ;
?>

Try it yourself

grammar

 strftime ( format , timestamp ) ;
parameter describe
format

Required. Specifies how to return the result:

  • %a - Abbreviation of the day of the week
  • %A - The full name of the day of the week
  • %b - Abbreviation of the month name
  • %B - The full name of the month name
  • %c - preferred date and time notation
  • %C - a number representing the century (year divided by 100, ranging from 00 to 99)
  • %d - What day of the month (01 to 31)
  • %D - Time format, same as %m/%d/%y notation
  • %e - What day of the month (1 to 31)
  • %g - Similar to %G notation, but without century
  • %G - 4-digit year corresponding to the ISO week number (see %V)
  • %h - Same as %b notation
  • %H - hours, on a 24-hour schedule (00 to 23)
  • %I - hours, using a 12-hour system (01 to 12)
  • %j - What day of the year (001 to 366)
  • %m - Month (01 to 12)
  • %M - points
  • %n - newline
  • %p - am or pm corresponding to the given time value
  • %r - time stamping method of am and pm
  • %R - 24-hour time stamping method
  • %S - seconds
  • %t - tab tab character
  • %T - Current time, the same as the %H:%M:%S representation
  • %u - The number of the day of the week (1 to 7), Monday [Monday] = 1. Warning: On Sun Solaris system, Sunday [Sunday] = 1
  • %U - The number of weeks included in the year, starting from the first Sunday, as the first day of the first week
  • %V - The number of weeks (01 to 53) contained in the ISO 8601 format included in the year. Week 1 means that the first week of the year must have at least four days, and Monday is the first day of the week
  • %W - The number of weeks included in the year, starting from the first Monday, as the first day of the first week
  • %w - represents a day of the week in decimal form, Sunday [Sunday] = 0
  • %x - preferred date notation without time
  • %X - preferred time notation without date
  • %y - A representation of year that does not contain a number representing the century (range from 00 to 99)
  • %Y - A representation of the year that contains the number representing the century
  • %Z or %z - Time zone name or abbreviation
  • %% - Output a % character
timestamp Optional. Specifies a Unix timestamp that represents the date/time that needs to be formatted. The default is the current time ( time() ).
Similar Functions
Popular Articles